﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HomeWork4_2
{
    internal class Program
    {
        static void Main(string[] args)
        {
            List<int> list = new List<int>();
            Random random = new Random();
            for (int i = 0; i < 100; i++)
            {
                int a=random.Next(1000);
                list.Add(a);
            }
            Console.WriteLine("生成如下：");
            foreach (var n in list)
            {
                Console.Write(n + "\t");
            }

            var query = from num in list
                        where true
                        orderby num descending
                        select num;
            int sum = query.Sum();
            int count = query.Count();
            Console.WriteLine("\n排序如下：");
            foreach(var n in query)
            {
                Console.Write(n + "\t");
            }
            Console.WriteLine("\n和为：" + sum + ",平均值为：" + sum / count);
            Console.Read();
        }
    }
}
